package com.xxcxcxcx.jobsystem.common.Job.Endurance;

import com.xxcxcxcx.jobsystem.PlayerSaveData;
import com.xxcxcxcx.jobsystem.common.Job.JobBase;
import com.xxcxcxcx.jobsystem.common.JobsClass;
import com.xxcxcxcx.jobsystem.common.capability.JobCapability;
import com.xxcxcxcx.jobsystem.common.capability.JobCapabilityProvider;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.common.util.LazyOptional;

import java.util.UUID;

public class Endurance extends JobBase {
    public static String Job = JobsClass.Endurance;
    public static AttributeModifier[] Endurances={new AttributeModifier(UUID.randomUUID(), "Endurance change 1", 2, AttributeModifier.Operation.ADDITION),
            new AttributeModifier(UUID.randomUUID(), "Endurance change 2", 2, AttributeModifier.Operation.ADDITION),
            new AttributeModifier(UUID.randomUUID(), "Endurance change 3", 2, AttributeModifier.Operation.ADDITION),
            new AttributeModifier(UUID.randomUUID(), "Endurance change 4", 2, AttributeModifier.Operation.ADDITION),
            new AttributeModifier(UUID.randomUUID(), "Endurance change 5", 2, AttributeModifier.Operation.ADDITION),
            new AttributeModifier(UUID.randomUUID(), "Endurance change 6", 2, AttributeModifier.Operation.ADDITION),
            new AttributeModifier(UUID.randomUUID(), "Endurance change 7", 2, AttributeModifier.Operation.ADDITION),
            new AttributeModifier(UUID.randomUUID(), "Endurance change 8", 2, AttributeModifier.Operation.ADDITION),
            new AttributeModifier(UUID.randomUUID(), "Endurance change 9", 2, AttributeModifier.Operation.ADDITION),
            new AttributeModifier(UUID.randomUUID(), "Endurance change 10", 2, AttributeModifier.Operation.ADDITION),};
    public static void UpExperienceChange(Player player, double num, String Job){
        LazyOptional<JobCapability> capability = JobCapabilityProvider.getPlayerData(player);
        if(!capability.isPresent()) {
            return;
        }
        PlayerSaveData playerSaveData = capability.orElse(null);
        int level = playerSaveData.getLevel(Job);
        if(level>=4&&num<4)num=0;
        if(level>=4&&num<10)num*=0.7;
        if(level>=7&&num<10)num=0;
        if(level>=7&&num<20)num*=0.5;
        if(num==0)return;
        if(playerSaveData.getExperienceCD(Job)!=0){
            return;
        }else playerSaveData.setExperienceCD(Job,60);
        UpExperience(player,num,Job);
    }
}
